/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biermanager.componentes;

import biermanager.interfaceGrafica.JFramePrincipal;
import java.awt.Color;
import java.awt.LinearGradientPaint;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.painter.CompoundPainter;
import org.jdesktop.swingx.painter.ImagePainter;
import org.jdesktop.swingx.painter.MattePainter;
import org.jdesktop.swingx.painter.Painter;

/**
 *
 * @author Tiago Silva Loureiro
 */
public class PainelDeTopo extends JXPanel {

    public PainelDeTopo( String caminhoDaImagem ){
        this.setBackgroundPainter(getPainter(caminhoDaImagem));
        this.setOpaque(true);
    }

    private Painter getPainter( String caminhoDaImagem ){
    Color cor1 = new Color(190, 54, 54);
    Color cor2 = new Color(140, 4, 4 );
     BufferedImage background = null;
        try {
            background = ImageIO.read(getClass().getResource("/biermanager/imagens/passo1.png"));
        } catch (IOException ex) {
            Logger.getLogger(JFramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
     ImagePainter img = new ImagePainter(background);
     MattePainter mp2 = new MattePainter(new Color(190,54, 54));
     MattePainter mp3 = new MattePainter(new Color(140,4, 4));
     Point2D start = new Point2D.Float(0, 0);
     Point2D end = new Point2D.Float(this.getHeight() - 1, this.getWidth() - 1);
     float[] dist = {0.0f, 1.0f};
     Color[] colors = {cor1, cor2};
     LinearGradientPaint p =
         new LinearGradientPaint(start, end, dist, colors);
     MattePainter mp = new MattePainter(p);
     CompoundPainter cp = new CompoundPainter(img,mp2);
     return (new CompoundPainter(mp,cp));
  }
}
